#!/bin/bash
# Copyright © 2005-2019 ChinaVenture Investment Consulting Ltd.

set -x
#==========================
# JVM Configuration
#==========================
#JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${CUSTOM_LOGGING_PATH}/${APP_NAME}/${HOSTNAME}/oom_heapdump.hprof"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"

#==========================
# Setting system properties
#==========================
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/bin/${APP_NAME}.jar"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
#JAVA_OPT="${JAVA_OPT} --spring.profiles.active=${PROFILES_ACTIVE}"
#JAVA_OPT="${JAVA_OPT} --spring.cloud.nacos.discovery.namespace=${NACOS_NAMESPACE}"
#JAVA_OPT="${JAVA_OPT} --spring.cloud.nacos.config.namespace=${NACOS_NAMESPACE}"

echo "${JAVA} ${JAVA_OPT}" > ${CUSTOM_LOGGING_PATH}/${APP_NAME}/${HOSTNAME}/start.out 2>&1 &
nohup ${JAVA} ${JAVA_OPT} > /dev/null 2>&1